package com.yykj.hospital.server.converter;

import com.yykj.hospital.client.dto.HospitalDepartmentDTO;
import com.yykj.hospital.server.model.entity.HospitalDepartment;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import java.util.List;
import java.util.stream.Collectors;

/**
 * Created by chendg on 2021/9/9 0009.
 */
@Data
public class DepartmentConverter {

	public static HospitalDepartmentDTO convert(HospitalDepartment hospitalDepartment) {
		HospitalDepartmentDTO hospitalDepartmentDTO = new HospitalDepartmentDTO();
		BeanUtils.copyProperties(hospitalDepartment, hospitalDepartmentDTO);
		return hospitalDepartmentDTO;
	}

	public static List<HospitalDepartmentDTO> convert(List<HospitalDepartment> list) {
		return list.stream().map(DepartmentConverter::convert)
				.collect(Collectors.toList());
	}

}
